<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<script type="text/javascript" src='resources/js/global/global.ca.js'></script>
<script type="text/javascript" src='resources/js/popup.js'></script>


<script>
	
	$(function(){
		
		$("#box-search-tabs li").click(function(){
			$("#box-search-tabs li").removeClass("current").removeClass("active");
			if (!$(this).hasClass("active")) {
				$(this).addClass("active");
			}
			$(this).addClass("current");
			if ($(this).attr("id")) {
				$("#box-search-forms form").css("display", "none");
				$("#frm_" + $(this).attr("id")).css("display", "block");
			}
		});
		
		KX.sugg_init_skb_fr(10, "highlightg", "highlighth", "lh", "t_from", "container1", 1, "frm_cxzz");
		KX.sugg_init_skb_fr(10, "highlightg", "highlighth", "lh", "t_to", "container2", 1, "frm_cxzz");
		KX.sugg_init_skb_fr(10, "highlightg", "highlighth", "lh", "t_stationname", "container3", 1, "frm_cxcz");
		
		$.each($("#box-search-tabs li"), function(){
			$(this).click(function(){
				var frm_id = $(this).attr("id");
				if ($("#frm_" + frm_id).find("div[id^=container]").size() > 0) {
					$.each($("#frm_" + frm_id).find("div[id^=container]"), function(){
						if (!$(this).attr("stat") && $(this).attr("stat") != "adjusted") {
							// style adjusted against container
							if ($("#" + $(this).attr("alt")).size() > 0) {
								var left_h = $("#" + $(this).attr("alt")).offset().left;
								var left_p = $("#frm_" + frm_id).offset().left;
								if ($("#frm_" + frm_id).css("margin-left")) {
									left_h += parseInt($("#frm_" + frm_id).css("margin-left"));
								}
								$(this).css("left", (left_h - left_p) + "px").attr("stat", "adjusted");
							}
						}
					});
				}
			});
		});	
		
		$("#cxcc").click(function(){
		alert("aa");
			$.ajax({
					type: "POST",
					url: "admin/account/finduncheck",
					success: function(){
								
								$.blockUI({ 
						            message:  "用户删除成功!", 
						            fadeIn: 700, 
						            fadeOut: 700, 
						            timeout: 2000, 
						            showOverlay: false, 
						            centerY: false, 
						            css: { 
						                width: '300px', 
						                top: '80px', 
						                left: ($(window).width()-300)/2 + 'px', 
						                padding: '10px 0px 0px 0px', 
						                height:'30px',
						                backgroundColor: '#fff',
						                '-webkit-border-radius': '10px', 
						                '-moz-border-radius': '10px', 
						                color: '#000' 
						            } 
						        });
						   }
						 });
		});
		
		$(".delete").click(function(){
			var id=$(this).parent().parent().attr("id");
			var t=$(this);
			$.ajax({
					type: "POST",
					url: "admin/account/delete",
					data: {"id":id},
					success: function(data){
								t.parent().parent().css("display","none");
								alert("删除成功");
								location.reload();
						   }
					});
		});


		$.each($(".view"),function(){
			$(this).click(function(){
				var id=$(this).parent().parent().attr("id");
				ShowIframe("123","http://localhost:8080/eduapp/admin/account/detail?id="+id,800,500);
			});	
		});
		
		<!--添加用户-->
		$("#add").click(function(){
			ShowIframe("123","http://localhost:8080/eduapp/admin/account/intoadd",800,500);
		});
		
		<!--excel导入-->
		$("#import").click(function(){
			$("#import").parent().find(".dr").css("display","inline");
			/*$("#import").parent().append(
			"&nbsp;<input type='file' size='12' id='path' name='filename' class='text' value='${accountPassword}'/><input type='button' id='buttonsave' class='sbtn excelsave' value='导入' /><input type='button' id='buttoncancel'class='sbtn' value='取消'/>"						
			);*/
		});
		
		$(".ecancle").live("click", function(){
				$(".dr").css("display","none");
		});
		
		$(".excelsave").live("click", function(){
			var path=$(".path").val();
			$.ajax({
					type: "POST",
					url: "admin/account/import",
					data: {"path":path},
					success: function(data){
								alert("导入成功！");
								$(this).parent().css("display","none");
						   }
						 });
		});
		
		<!--excel导出-->
		$("#export").click(function(){
			//alert("1a");
			var name=$(".accountRealName").val();
			var no=$(".accountNo").val();
			var maj=$(".accountMajority").val();
			var cla=$(".accountClass").val();
			
			$.ajax({
					type: "POST",
					url: "admin/account/export",
					data: {"name":name,"no":no,"maj":maj,"cla":cla},
					success: function(data){
								//alert(pass);
								alert("导出成功！")
						   }
						 });
		});
		
		$.each($(".passchange"),function(){
			$(this).click(function(){
			var id=$(this).parent().parent().attr("id");
			alert(id);
			$(this).parent().find("div").css("display","inline");
	        /*$(this).parent().append(
			"<div class='pc'><br>&nbsp;<input type='text' size='11' id='pass' name='accountPassword' class='text' value='${accountPassword}'/>&nbsp<input type='button' id='buttonsave' class='sbtn save' value='保存' />&nbsp<input type='button' id='buttoncancel'class='sbtn pcancle' value='取消' /></div>"
										
			);*/
			});
		});
		
		$(".pcancle").live("click", function(){
				$(".pc").css("display","none");
		});
		
		$(".save").live("click", function(){
			alert("1a");
			var id=$(this).parent().parent().parent().attr("id");
			alert(id);
			var pass=$(".pass"+id).val();
			alert(pass);
			$.ajax({
					type: "POST",
					url: "admin/account/passchange",
					data: {"id":id,"pass":pass},
					success: function(data){
								//alert(pass);
								$(".pc").css("display","none");
						   }
						 });
		});
		<!---->
		$.each($(".page-numbers"),function(){
			$(this).click(function(){
				var id=$(this).attr("id");
				alert(id);
				var name=$(".accountRealName").val();
				var no=$(".accountNo").val();
				var maj=$(".accountMajority").val();
				var cla=$(".accountClass").val();
				alert(name);
			$.ajax({
					type: "POST",
					url: "admin/account/search"+id,
					data: {"name":name,"no":no,"maj":maj,"cla":cla},
					success: function(data){
								//alert(pass);
								
						   }
						 });
				//ShowIframe("123","http://localhost:8080/train/admin/account/detail?id="+id,800,500);
			});	
		});
		
	});

</script>

<div id="panel-left" style="margin-top:10px;margin-bottom:10px">
	<div id="box-news">
			<table cellspacing="0" cellpadding="0" width="98%">
				<tr>
					<td colspan="3">
						<table cellspacing="0" cellpadding="0" width="100%">
							<tr>
								<td class="title_banner_left"></td>
								<td class="title_banner_center"><span class="banner_header">用户管理</span></td>
								<td class="title_banner_right"></td>
							</tr>
						</table>
					</td>
				</tr>
                <tr>
                <td class="box_left"></td>
                <td>
                	<!--查询表单-->
           	<div class="box" style="margin-top:10px;">
				<table cellspacing="0" cellpadding="0" border="0" width="90%" align="center">
                    <col width="6px" />
                    <col width="946px" />
                    <col width="6px" />
						<tr>
                            <td class="box_top_l"></td>
                            <td class="box_top_c box_title">查询条件</td>
                            <td class="box_top_r"></td>
						</tr>
                        <tr >
                        	<td class="box_left"></td>
                            <td>
                            <div class="p" style="margin-top:10px;">
					<form action="admin/account/search/1" method="post" id="frm_cxzz" >
						<div class="p">
                        	 <table width="80%" cellpadding="0" cellspacing="0" border="0" style="text-align:center;" class="datagrid" align="center">
                             	<tr>
                                	<td>姓名:</td><td><span><input type="text" size="12" name="accountRealName" class="text accountRealName" value="${accountRealName}" id="accountRealName" /></span></td>
									<td>学号:</td><td><span> <input type="text" size="12" name="accountNo" class="text accountNo" value="${accountNo}" id="accountNo" /></span></td>
                           		    <td>专业:</td><td><span> <input type="text" size="12" name="accountMajority" class="text accountMajority" value="${accountMajority}" id="accountMajority" /></span></td>
                                </tr>
                                <tr>
                           			<td>班级:</td><td><span> <input type="text" size="12" name="accountClass" class="text accountClass" value="${accountClass}" id="accountClass" /></span></td>
                               		<td>提交:</td><td><input  width="50" type="submit" value="查询" class="sbtn" id="search"/></td>
                                </tr>
                             </table>
                             </div>
                             </form>
				</div>
                            
                            
                            </td>
                			 <td class="box_right"></td>
                        </tr>
                        <tr>
                            <td class="box_btm_l"></td>
                            <td class="box_btm_c"></td>
                            <td class="box_btm_r"></td>
						</tr>
                 </table>
            </div>
                
                
            	<div class="box" style="margin-top:10px;">
				<table cellspacing="0" cellpadding="0" border="0" width="90%" align="center">
                    <col width="6px" />
                    <col width="946px" />
                    <col width="6px" />
						<tr>
                            <td class="box_top_l"></td>
                            <td class="box_top_c box_title">查询结果</td>
                            <td class="box_top_r"></td>
						</tr>
                        <tr >
                        	<td class="box_left"></td>
                            <td>
                            <div align="center" style="margin-top:10px;">      
                            <table width="95%" cellpadding="0" cellspacing="0" border="1" style="text-align:center;" class="datagrid">
                                <thead>
                                    <tr <c:if test="${idx % 2 == 1}">bgcolor="#fafbf5"</c:if>>
                                 		<td><input type="checkbox" id='ckall' /></td>
                                        <td>用户名</td>
                                        <td>姓名</td>
                                        <td>学号</td>
                                        <td>专业年级</td>
                                        <td>用户类型</td>
                                        <td>操作</td>
                                    </tr>
                                </thead>
                                    <logic:present name="result.page">
                                        <logic:iterate name="result.page" property="items" id="entity">
                                                    <tr id="${entity.id}">
                                                    	<td><input type="checkbox" id='ckall' /></td>
                                                        <td>${entity.accountNo}</td>
                                                        <td>${entity.accountRealName}</td>
                                                        <td>${entity.accountNo}</td>
                                                        <td>${entity.accountClass}</td>
                                                        <td>${entity.accountRole.roleName}</td> 
                                                        <td width='40%'>
                                                        	
                                                            <input type="button" id="view" value="查看" class="sbtn view"  />
                                                        	<input type="button" value="删除" id="delete" class="sbtn delete"  />
                                                        	<input type="button" value="重设密码" id="passchange" class="sbtn passchange" />
                                                       	  <div class='pc' style="display:none"><br>&nbsp;<input type='text' size='11' id='pass' name='accountPassword' class='text pass${entity.id}' value=''/>&nbsp<input type='button' id='buttonsave' class='sbtn save' value='保存' />&nbsp<input type='button' id='buttoncancel'class='sbtn pcancle' value='取消' /></div>                                                        </td>
                                                    </tr>
                                        </logic:iterate>
                                    </logic:present>
                                <tbody>
                                </tbody>
                            </table>
                      <!-- Pagination Support-->
                                    <div class="tablenav-pages" align="right">
                                        <logic:notEmpty name="result.page">
                                            <span class="displaying-num">
                                                显示 
                                                <bean:write name="result.page" property="currentPageStartIndex" />
                                                –
                                                <bean:write name="result.page" property="currentPageEndIndex" /> 
                                                共 
                                                <bean:write name="result.page" property="totalCount" />
                                            </span>
                                            <bean:define id="currentPage" name="result.page" property="currentPage" />
                                            <logic:iterate id="pageIndex" name="result.page" property="pages">
                                                <c:choose>
                                                    <c:when test="${pageIndex eq currentPage}">
                                                        <span id="currentPage" class="page-numbers current"><c:out value="${pageIndex}" /></span>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <a  href="admin/account/page/<c:out value='${pageIndex}'/>" class="${pageIndex}">
                                                            <c:out value="${pageIndex}" />
                                                        </a>
                                                    </c:otherwise>
                                                </c:choose>
                                            </logic:iterate>
                                        </logic:notEmpty>
                                    </div>                  
           			 </div>    
                            
                            
                            </td>
                			 <td class="box_right"></td>
                        </tr>
                        <tr>
                            <td class="box_btm_l"></td>
                            <td class="box_btm_c"></td>
                            <td class="box_btm_r"></td>
						</tr>
                 </table>
            </div>
                <table width="80%" cellpadding="0" cellspacing="0" border="0" style="text-align:center;" class="datagrid" >
                    <tr>
                    	<td>
                        <input type="button" value="添加" id="add" class="sbtn" />
                        </td>
                        <td>
                    	<input type="button" value="导入" id="import" class="sbtn" />
                        <div class="dr" style="display:none">
                        <input type='file' size='12' id='path' name='filename' class='text path' value='${accountPassword}'/><input type='button' id='buttonsave' class='sbtn excelsave' value='导入' />
                        <input type='button' id='buttoncancel'class='sbtn ecancle' value='取消'/>"	
                        </div>
                        </td>
                        <td>
                        <input type="button" value="导出" id="export" class="sbtn" />
                        </td>
                       
                        </tr>
				</table>
                </td>
                <td class="box_right"></td>
                </tr>
                <tr>
					<td class="box_btm_l"></td>
					<td class="box_btm_c" width="678px"></td>
					<td class="box_btm_r"></td>
				</tr>
			</table>
     </div>
</div>

